import axios from "axios";

const service = axios.create({
  baseURL: "http://localhost:3000/",
  // baseURL: '',
  timeout: 30000,
  headers: {
    "Content-Type": "application/json;charset=UTF-8", //表单数据类型
  },
  withCredentials: true, //自动获取后台服务器cookie同步到本地
});
// 请求拦截器
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);
// 响应拦截器
service.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    return Promise.reject(error);
  }
);
export default service;
